<?php
declare(strict_types=1);

namespace app\validate;

class UserValidate extends BaseValidate
{
    protected $rule = [
        'code' => 'require|length:6',
        'mobile' => 'require|mobile',
        'nickname' => 'length:1,50',
        'avatar' => 'url',
        'gender' => 'in:0,1,2',
        'country' => 'length:1,50',
        'province' => 'length:1,50',
        'city' => 'length:1,50'
    ];

    protected $message = [
        'code.require' => '验证码不能为空',
        'code.length' => '验证码长度必须为6位',
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号格式不正确',
        'nickname.length' => '昵称长度必须在1-50个字符之间',
        'avatar.url' => '头像必须是有效的URL地址',
        'gender.in' => '性别值不正确',
        'country.length' => '国家长度必须在1-50个字符之间',
        'province.length' => '省份长度必须在1-50个字符之间',
        'city.length' => '城市长度必须在1-50个字符之间'
    ];

    // 微信登录场景
    public function sceneWxLogin(): UserValidate
    {
        return $this->only(['code', 'nickname', 'avatar', 'gender', 'country', 'province', 'city']);
    }

    // 手机号登录场景
    public function sceneMobileLogin(): UserValidate
    {
        return $this->only(['mobile', 'code']);
    }

    // 发送验证码场景
    public function sceneSendCode(): UserValidate
    {
        return $this->only(['mobile']);
    }

    // 绑定手机号场景
    public function sceneBindMobile(): UserValidate
    {
        return $this->only(['mobile', 'code']);
    }
} 